package com.javaee.ex05.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;


// 基于xml方式实现面向切面编程
// XmlAspect是切面，beforeAdvice是通知
public class XmlAspect {
    // 前置通知
    public void beforeAdvice(JoinPoint joinPoint) {
        System.out.println("前置通知 beforeAdvice");
        System.out.println("目标类：" + joinPoint.getTarget());
        System.out.println("目标方法：" + joinPoint.getSignature().getName());
    }
    // 注意在环绕通知当中方法需要有返回值类型 ProceedingJoinPoint proceedingJoinPoint
    // 环绕通知  环绕通知-目标方法-环绕通知
    public Object aroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知开始 aroundAdvice");
        // 执行目标方法
        Object object = proceedingJoinPoint.proceed();
        System.out.println("环绕通知结束 aroundAdvice");
        return object;
    }
}
